<template>
  <view>
    <view class="header">
      <view class="userinfo">
        <view class="face"><image :src="userinfo.face"></image></view>
        <view class="info">
          <view class="username">{{ userinfo.username }}</view>
          <view class="integral">积分:{{ userinfo.integral }}</view>
        </view>
      </view>
    </view>
    <view class="list">
      <view
        class="li"
        v-for="(li, li_i) in severList"
        @tap="toPage(li.name, li_i)"
        hover-class="hover"
        :key="li_i"
      >
        <view class="icon"
          ><image
            :src="'../../static/HM-PersonalCenter/sever/' + li.icon"
          ></image
        ></view>
        <view class="text">{{ li.name }}</view>
        <image class="to" src="../../static/HM-PersonalCenter/to.png"></image>
      </view>
    </view>
  </view>
</template>
<script>
export default {
  data() {
    return {
      userinfo: {},
      severList: [
          { name: "我的订单", icon: "dingdan.png" },
          { name: "我的文章", icon: "wenzhangfenlei.png" },
          { name: "社区公告", icon: "gonggao.png" },
          { name: "联系我们", icon: "lianxi.png" },
      ]
    };
  },
  onLoad() {
    //加载
    this.init();
  },
  methods: {
    init() {
      let user = JSON.parse(this.$store.state.user.userInfo)
      console.log(user);
      //用户信息
      this.userinfo = {
        face: user.photoUrl,
        username: user.nickName,
        integral: "1435"
      };
    },
    //用户点击列表项
    toPage(list_i, li_i) {
      console.log(list_i, li_i);
      switch (list_i) {
        case '联系我们':
          this.customerFn()
          break;
        case '我的文章':
          uni.navigateTo({
             url: '../article/index'
          });
          break;
        case '我的订单':
          uni.navigateTo({
             url: '../orderList/index'
          });
          break;
        case '社区公告':
          uni.navigateTo({
             url: '../notice/index'
          });
          break;
        default:
          break;
      }
    },
    customerFn(){
      wx.makePhoneCall({
        phoneNumber: '13128716617',
        success: function () {
          console.log("拨号成功！")
        },
        fail: function () {
          console.log("拨号失败！")
        }
      })
    }
  }
};
</script>

<style lang="scss">
page {
  background-color: #fff;
}
.header {
  // background-color: #11998e;
  background-color: #ff6364;
  width: 100%;
  height: 30vw;
  padding: 0 4%;
  display: flex;
  align-items: center;
  .userinfo {
    width: 90%;
    display: flex;
    .face {
      flex-shrink: 0;
      width: 15vw;
      height: 15vw;
      image {
        width: 100%;
        height: 100%;
        border-radius: 100%;
      }
    }
    .info {
      display: flex;
      flex-flow: wrap;
      padding-left: 30upx;
      .username {
        width: 100%;
        color: #fff;
        font-size: 40upx;
      }
      .integral {
        display: flex;
        align-items: center;
        padding: 0 20upx;
        height: 40upx;
        color: #fff;
        background-color: rgba(0, 0, 0, 0.1);
        border-radius: 20upx;
        font-size: 24upx;
      }
    }
  }
  .setting {
    flex-shrink: 0;
    width: 6vw;
    height: 6vw;
    image {
      width: 100%;
      height: 100%;
    }
  }
}
.hover {
  background-color: #eee;
}
.orders {
  background-color: #ff6364;
  width: 100%;
  height: 11vw;
  padding: 0 4%;
  margin-bottom: calc(11vw + 40upx);
  display: flex;
  align-items: flex-start;
  border-radius: 0 0 100% 100%;
  margin-top: -1upx;
  .box {
    width: 98%;
    padding: 0 1%;
    height: 22vw;
    background-color: #fefefe;
    border-radius: 24upx;
    box-shadow: 0 0 20upx rgba(0, 0, 0, 0.15);
    margin-bottom: 40upx;
    display: flex;
    align-items: center;
    justify-content: center;
    .label {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-flow: wrap;
      width: 100%;
      height: 16vw;
      color: #666666;
      font-size: 26upx;
      .icon {
        position: relative;
        width: 7vw;
        height: 7vw;
        margin: 0 1vw;
        .badge {
          position: absolute;
          width: 4vw;
          height: 4vw;
          background-color: #ec6d2c;
          top: -1vw;
          right: -1vw;
          border-radius: 100%;
          font-size: 20upx;
          color: #fff;
          display: flex;
          align-items: center;
          justify-content: center;
          z-index: 10;
        }
        image {
          width: 7vw;
          height: 7vw;
          z-index: 9;
        }
      }
    }
  }
}
.list {
  width: 100%;
  .li {
    width: 100%;
    height: 100upx;
    padding: 0 4%;
    border-bottom: solid 1upx #e7e7e7;
    display: flex;
    align-items: center;
    .icon {
      flex-shrink: 0;
      width: 50upx;
      height: 50upx;
      image {
        width: 50upx;
        height: 50upx;
      }
    }
    .text {
      padding-left: 20upx;
      width: 100%;
      color: #666;
    }
    .to {
      flex-shrink: 0;
      width: 40upx;
      height: 40upx;
    }
  }
}
</style>
